<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>实战二</title>
	<link rel="stylesheet" href="">
	<script type="text/javascript" src="../js/jquery-2.1.1.js"></script>
	<script type="text/javascript">
	$("document").ready(function(){
		var url = "server2.php";
		var data = {"do":"first"};
		$.getJSON(url, data, function(res) {
				/*optional stuff to do after success */
				$("#username").val(res.username);
				$("#password").val(res.password);

		});
		var data = {"do":"second"};
		$.getJSON(url,data, function(res) {
				/*optional stuff to do after success */
				//当前文用索引数组定义时，可用下面方法
				$("#members").val(res[1].password);
				//当前文用关联数组定义时，可用下面方法
				//$("#members").val(res.two.address);
				//$("#members").val(res['two'].password);
		});



		var data = {"do":"third"};
		$.getJSON(url,data, function(res) {
				/*optional stuff to do after success */
				//注意json的层次
				$("#address").val(res.address[1].username);
		});
	});
	</script>
</head>
<body>
	<h2>一维数组巩固练习</h2>
	<input type="text" name="username" id="username"/>
	<br/>
	<input type="password" name="password" id="password" />

	<h2>多维数组实战(展示一组会员信息)</h2>
	<textarea id="members"></textarea>

	<h2>对象实战(放一组地址信息)</h2>
	<textarea id="address"></textarea>
</body>
</html>